{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  },
  "orig_nbformat": 4,
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.7.1 64-bit ('Python3_7_2')"
  },
  "interpreter": {
   "hash": "ceed3ede7d2ae4746b1bde0ed48f83d28ba93d0b68e140a25bb2fbb7cbabeb22"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import pandas as pd "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "   Unnamed: 0  Age  Sex     ChestPain  RestBP  Chol  Fbs  RestECG  MaxHR  \\\n",
       "0           1   63    1       typical     145   233    1        2    150   \n",
       "1           2   67    1  asymptomatic     160   286    0        2    108   \n",
       "2           3   67    1  asymptomatic     120   229    0        2    129   \n",
       "3           4   37    1    nonanginal     130   250    0        0    187   \n",
       "4           5   41    0    nontypical     130   204    0        2    172   \n",
       "\n",
       "   ExAng  Oldpeak  Slope   Ca        Thal  AHD  \n",
       "0      0      2.3      3  0.0       fixed   No  \n",
       "1      1      1.5      2  3.0      normal  Yes  \n",
       "2      1      2.6      2  2.0  reversable  Yes  \n",
       "3      0      3.5      3  0.0      normal   No  \n",
       "4      0      1.4      1  0.0      normal   No  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Unnamed: 0</th>\n      <th>Age</th>\n      <th>Sex</th>\n      <th>ChestPain</th>\n      <th>RestBP</th>\n      <th>Chol</th>\n      <th>Fbs</th>\n      <th>RestECG</th>\n      <th>MaxHR</th>\n      <th>ExAng</th>\n      <th>Oldpeak</th>\n      <th>Slope</th>\n      <th>Ca</th>\n      <th>Thal</th>\n      <th>AHD</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>1</td>\n      <td>63</td>\n      <td>1</td>\n      <td>typical</td>\n      <td>145</td>\n      <td>233</td>\n      <td>1</td>\n      <td>2</td>\n      <td>150</td>\n      <td>0</td>\n      <td>2.3</td>\n      <td>3</td>\n      <td>0.0</td>\n      <td>fixed</td>\n      <td>No</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2</td>\n      <td>67</td>\n      <td>1</td>\n      <td>asymptomatic</td>\n      <td>160</td>\n      <td>286</td>\n      <td>0</td>\n      <td>2</td>\n      <td>108</td>\n      <td>1</td>\n      <td>1.5</td>\n      <td>2</td>\n      <td>3.0</td>\n      <td>normal</td>\n      <td>Yes</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>3</td>\n      <td>67</td>\n      <td>1</td>\n      <td>asymptomatic</td>\n      <td>120</td>\n      <td>229</td>\n      <td>0</td>\n      <td>2</td>\n      <td>129</td>\n      <td>1</td>\n      <td>2.6</td>\n      <td>2</td>\n      <td>2.0</td>\n      <td>reversable</td>\n      <td>Yes</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4</td>\n      <td>37</td>\n      <td>1</td>\n      <td>nonanginal</td>\n      <td>130</td>\n      <td>250</td>\n      <td>0</td>\n      <td>0</td>\n      <td>187</td>\n      <td>0</td>\n      <td>3.5</td>\n      <td>3</td>\n      <td>0.0</td>\n      <td>normal</td>\n      <td>No</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>5</td>\n      <td>41</td>\n      <td>0</td>\n      <td>nontypical</td>\n      <td>130</td>\n      <td>204</td>\n      <td>0</td>\n      <td>2</td>\n      <td>172</td>\n      <td>0</td>\n      <td>1.4</td>\n      <td>1</td>\n      <td>0.0</td>\n      <td>normal</td>\n      <td>No</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 2
    }
   ],
   "source": [
    "# csv_file = tf.keras.utils.get_file('heart.csv', 'https://storage.googleapis.com/applied-dl/heart.csv')\n",
    "df = pd.read_csv('heart.csv')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "Unnamed: 0      int64\n",
       "Age             int64\n",
       "Sex             int64\n",
       "ChestPain      object\n",
       "RestBP          int64\n",
       "Chol            int64\n",
       "Fbs             int64\n",
       "RestECG         int64\n",
       "MaxHR           int64\n",
       "ExAng           int64\n",
       "Oldpeak       float64\n",
       "Slope           int64\n",
       "Ca            float64\n",
       "Thal           object\n",
       "AHD            object\n",
       "dtype: object"
      ]
     },
     "metadata": {},
     "execution_count": 3
    }
   ],
   "source": [
    "df.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.Thal = pd.Categorical(df.Thal)\n",
    "df.Thal = df.Thal.cat.codes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "   Unnamed: 0  Age  Sex     ChestPain  RestBP  Chol  Fbs  RestECG  MaxHR  \\\n",
       "0           1   63    1       typical     145   233    1        2    150   \n",
       "1           2   67    1  asymptomatic     160   286    0        2    108   \n",
       "2           3   67    1  asymptomatic     120   229    0        2    129   \n",
       "3           4   37    1    nonanginal     130   250    0        0    187   \n",
       "4           5   41    0    nontypical     130   204    0        2    172   \n",
       "\n",
       "   ExAng  Oldpeak  Slope   Ca  Thal  AHD  \n",
       "0      0      2.3      3  0.0     0   No  \n",
       "1      1      1.5      2  3.0     1  Yes  \n",
       "2      1      2.6      2  2.0     2  Yes  \n",
       "3      0      3.5      3  0.0     1   No  \n",
       "4      0      1.4      1  0.0     1   No  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Unnamed: 0</th>\n      <th>Age</th>\n      <th>Sex</th>\n      <th>ChestPain</th>\n      <th>RestBP</th>\n      <th>Chol</th>\n      <th>Fbs</th>\n      <th>RestECG</th>\n      <th>MaxHR</th>\n      <th>ExAng</th>\n      <th>Oldpeak</th>\n      <th>Slope</th>\n      <th>Ca</th>\n      <th>Thal</th>\n      <th>AHD</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>1</td>\n      <td>63</td>\n      <td>1</td>\n      <td>typical</td>\n      <td>145</td>\n      <td>233</td>\n      <td>1</td>\n      <td>2</td>\n      <td>150</td>\n      <td>0</td>\n      <td>2.3</td>\n      <td>3</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>No</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2</td>\n      <td>67</td>\n      <td>1</td>\n      <td>asymptomatic</td>\n      <td>160</td>\n      <td>286</td>\n      <td>0</td>\n      <td>2</td>\n      <td>108</td>\n      <td>1</td>\n      <td>1.5</td>\n      <td>2</td>\n      <td>3.0</td>\n      <td>1</td>\n      <td>Yes</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>3</td>\n      <td>67</td>\n      <td>1</td>\n      <td>asymptomatic</td>\n      <td>120</td>\n      <td>229</td>\n      <td>0</td>\n      <td>2</td>\n      <td>129</td>\n      <td>1</td>\n      <td>2.6</td>\n      <td>2</td>\n      <td>2.0</td>\n      <td>2</td>\n      <td>Yes</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4</td>\n      <td>37</td>\n      <td>1</td>\n      <td>nonanginal</td>\n      <td>130</td>\n      <td>250</td>\n      <td>0</td>\n      <td>0</td>\n      <td>187</td>\n      <td>0</td>\n      <td>3.5</td>\n      <td>3</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>No</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>5</td>\n      <td>41</td>\n      <td>0</td>\n      <td>nontypical</td>\n      <td>130</td>\n      <td>204</td>\n      <td>0</td>\n      <td>2</td>\n      <td>172</td>\n      <td>0</td>\n      <td>1.4</td>\n      <td>1</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>No</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 5
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "   Unnamed: 0  Age  Sex     ChestPain  RestBP  Chol  Fbs  RestECG  MaxHR  \\\n",
       "0           1   63    1       typical     145   233    1        2    150   \n",
       "1           2   67    1  asymptomatic     160   286    0        2    108   \n",
       "2           3   67    1  asymptomatic     120   229    0        2    129   \n",
       "3           4   37    1    nonanginal     130   250    0        0    187   \n",
       "4           5   41    0    nontypical     130   204    0        2    172   \n",
       "\n",
       "   ExAng  Oldpeak  Slope   Ca  Thal  AHD  target  \n",
       "0      0      2.3      3  0.0     0   No       0  \n",
       "1      1      1.5      2  3.0     1  Yes       1  \n",
       "2      1      2.6      2  2.0     2  Yes       1  \n",
       "3      0      3.5      3  0.0     1   No       0  \n",
       "4      0      1.4      1  0.0     1   No       0  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Unnamed: 0</th>\n      <th>Age</th>\n      <th>Sex</th>\n      <th>ChestPain</th>\n      <th>RestBP</th>\n      <th>Chol</th>\n      <th>Fbs</th>\n      <th>RestECG</th>\n      <th>MaxHR</th>\n      <th>ExAng</th>\n      <th>Oldpeak</th>\n      <th>Slope</th>\n      <th>Ca</th>\n      <th>Thal</th>\n      <th>AHD</th>\n      <th>target</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>1</td>\n      <td>63</td>\n      <td>1</td>\n      <td>typical</td>\n      <td>145</td>\n      <td>233</td>\n      <td>1</td>\n      <td>2</td>\n      <td>150</td>\n      <td>0</td>\n      <td>2.3</td>\n      <td>3</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>No</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>2</td>\n      <td>67</td>\n      <td>1</td>\n      <td>asymptomatic</td>\n      <td>160</td>\n      <td>286</td>\n      <td>0</td>\n      <td>2</td>\n      <td>108</td>\n      <td>1</td>\n      <td>1.5</td>\n      <td>2</td>\n      <td>3.0</td>\n      <td>1</td>\n      <td>Yes</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>3</td>\n      <td>67</td>\n      <td>1</td>\n      <td>asymptomatic</td>\n      <td>120</td>\n      <td>229</td>\n      <td>0</td>\n      <td>2</td>\n      <td>129</td>\n      <td>1</td>\n      <td>2.6</td>\n      <td>2</td>\n      <td>2.0</td>\n      <td>2</td>\n      <td>Yes</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>4</td>\n      <td>37</td>\n      <td>1</td>\n      <td>nonanginal</td>\n      <td>130</td>\n      <td>250</td>\n      <td>0</td>\n      <td>0</td>\n      <td>187</td>\n      <td>0</td>\n      <td>3.5</td>\n      <td>3</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>No</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>5</td>\n      <td>41</td>\n      <td>0</td>\n      <td>nontypical</td>\n      <td>130</td>\n      <td>204</td>\n      <td>0</td>\n      <td>2</td>\n      <td>172</td>\n      <td>0</td>\n      <td>1.4</td>\n      <td>1</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>No</td>\n      <td>0</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 6
    }
   ],
   "source": [
    "df['target'] = pd.Categorical(df['AHD'])#.cat.codes\n",
    "df['target'] = df['target'].cat.codes\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "Index(['Unnamed: 0', 'Age', 'Sex', 'ChestPain', 'RestBP', 'Chol', 'Fbs',\n",
       "       'RestECG', 'MaxHR', 'ExAng', 'Oldpeak', 'Slope', 'Ca', 'Thal', 'AHD',\n",
       "       'target'],\n",
       "      dtype='object')"
      ]
     },
     "metadata": {},
     "execution_count": 7
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "   Age  Sex  RestBP  Chol  Fbs  RestECG  MaxHR  ExAng  Oldpeak  Slope   Ca  \\\n",
       "0   63    1     145   233    1        2    150      0      2.3      3  0.0   \n",
       "1   67    1     160   286    0        2    108      1      1.5      2  3.0   \n",
       "2   67    1     120   229    0        2    129      1      2.6      2  2.0   \n",
       "3   37    1     130   250    0        0    187      0      3.5      3  0.0   \n",
       "4   41    0     130   204    0        2    172      0      1.4      1  0.0   \n",
       "\n",
       "   Thal  target  \n",
       "0     0       0  \n",
       "1     1       1  \n",
       "2     2       1  \n",
       "3     1       0  \n",
       "4     1       0  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Age</th>\n      <th>Sex</th>\n      <th>RestBP</th>\n      <th>Chol</th>\n      <th>Fbs</th>\n      <th>RestECG</th>\n      <th>MaxHR</th>\n      <th>ExAng</th>\n      <th>Oldpeak</th>\n      <th>Slope</th>\n      <th>Ca</th>\n      <th>Thal</th>\n      <th>target</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>63</td>\n      <td>1</td>\n      <td>145</td>\n      <td>233</td>\n      <td>1</td>\n      <td>2</td>\n      <td>150</td>\n      <td>0</td>\n      <td>2.3</td>\n      <td>3</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>67</td>\n      <td>1</td>\n      <td>160</td>\n      <td>286</td>\n      <td>0</td>\n      <td>2</td>\n      <td>108</td>\n      <td>1</td>\n      <td>1.5</td>\n      <td>2</td>\n      <td>3.0</td>\n      <td>1</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>67</td>\n      <td>1</td>\n      <td>120</td>\n      <td>229</td>\n      <td>0</td>\n      <td>2</td>\n      <td>129</td>\n      <td>1</td>\n      <td>2.6</td>\n      <td>2</td>\n      <td>2.0</td>\n      <td>2</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>37</td>\n      <td>1</td>\n      <td>130</td>\n      <td>250</td>\n      <td>0</td>\n      <td>0</td>\n      <td>187</td>\n      <td>0</td>\n      <td>3.5</td>\n      <td>3</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>41</td>\n      <td>0</td>\n      <td>130</td>\n      <td>204</td>\n      <td>0</td>\n      <td>2</td>\n      <td>172</td>\n      <td>0</td>\n      <td>1.4</td>\n      <td>1</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>0</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 8
    }
   ],
   "source": [
    "#去除掉一些字符串信息\n",
    "df = df.drop(columns=['Unnamed: 0','ChestPain','AHD'])\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = df.dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "   Age  Sex  RestBP  Chol  Fbs  RestECG  MaxHR  ExAng  Oldpeak  Slope   Ca  \\\n",
       "0   63    1     145   233    1        2    150      0      2.3      3  0.0   \n",
       "1   67    1     160   286    0        2    108      1      1.5      2  3.0   \n",
       "2   67    1     120   229    0        2    129      1      2.6      2  2.0   \n",
       "3   37    1     130   250    0        0    187      0      3.5      3  0.0   \n",
       "4   41    0     130   204    0        2    172      0      1.4      1  0.0   \n",
       "\n",
       "   Thal  target  \n",
       "0     0       0  \n",
       "1     1       1  \n",
       "2     2       1  \n",
       "3     1       0  \n",
       "4     1       0  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Age</th>\n      <th>Sex</th>\n      <th>RestBP</th>\n      <th>Chol</th>\n      <th>Fbs</th>\n      <th>RestECG</th>\n      <th>MaxHR</th>\n      <th>ExAng</th>\n      <th>Oldpeak</th>\n      <th>Slope</th>\n      <th>Ca</th>\n      <th>Thal</th>\n      <th>target</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>63</td>\n      <td>1</td>\n      <td>145</td>\n      <td>233</td>\n      <td>1</td>\n      <td>2</td>\n      <td>150</td>\n      <td>0</td>\n      <td>2.3</td>\n      <td>3</td>\n      <td>0.0</td>\n      <td>0</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>67</td>\n      <td>1</td>\n      <td>160</td>\n      <td>286</td>\n      <td>0</td>\n      <td>2</td>\n      <td>108</td>\n      <td>1</td>\n      <td>1.5</td>\n      <td>2</td>\n      <td>3.0</td>\n      <td>1</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>67</td>\n      <td>1</td>\n      <td>120</td>\n      <td>229</td>\n      <td>0</td>\n      <td>2</td>\n      <td>129</td>\n      <td>1</td>\n      <td>2.6</td>\n      <td>2</td>\n      <td>2.0</td>\n      <td>2</td>\n      <td>1</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>37</td>\n      <td>1</td>\n      <td>130</td>\n      <td>250</td>\n      <td>0</td>\n      <td>0</td>\n      <td>187</td>\n      <td>0</td>\n      <td>3.5</td>\n      <td>3</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>41</td>\n      <td>0</td>\n      <td>130</td>\n      <td>204</td>\n      <td>0</td>\n      <td>2</td>\n      <td>172</td>\n      <td>0</td>\n      <td>1.4</td>\n      <td>1</td>\n      <td>0.0</td>\n      <td>1</td>\n      <td>0</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 10
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "299"
      ]
     },
     "metadata": {},
     "execution_count": 11
    }
   ],
   "source": [
    "len(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "my_train_data = df.sample(frac=0.8,random_state=123)\n",
    "my_test_data = df.drop(my_train_data.index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "239 60\n"
     ]
    }
   ],
   "source": [
    "print(len(my_train_data),len(my_test_data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "target = my_train_data.pop('target')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "              Age         Sex      RestBP        Chol         Fbs     RestECG  \\\n",
       "count  239.000000  239.000000  239.000000  239.000000  239.000000  239.000000   \n",
       "mean    54.602510    0.665272  130.958159  248.066946    0.133891    1.004184   \n",
       "std      9.170477    0.472886   16.700473   51.884930    0.341250    0.993669   \n",
       "min     29.000000    0.000000   94.000000  126.000000    0.000000    0.000000   \n",
       "25%     48.000000    0.000000  120.000000  212.000000    0.000000    0.000000   \n",
       "50%     56.000000    1.000000  130.000000  243.000000    0.000000    1.000000   \n",
       "75%     61.000000    1.000000  140.000000  276.500000    0.000000    2.000000   \n",
       "max     77.000000    1.000000  192.000000  564.000000    1.000000    2.000000   \n",
       "\n",
       "            MaxHR       ExAng     Oldpeak       Slope          Ca        Thal  \n",
       "count  239.000000  239.000000  239.000000  239.000000  239.000000  239.000000  \n",
       "mean   149.661088    0.317992    1.047699    1.581590    0.661088    1.301255  \n",
       "std     23.658064    0.466674    1.140795    0.594651    0.920240    0.615997  \n",
       "min     71.000000    0.000000    0.000000    1.000000    0.000000   -1.000000  \n",
       "25%    132.500000    0.000000    0.000000    1.000000    0.000000    1.000000  \n",
       "50%    153.000000    0.000000    0.800000    2.000000    0.000000    1.000000  \n",
       "75%    166.500000    1.000000    1.600000    2.000000    1.000000    2.000000  \n",
       "max    202.000000    1.000000    6.200000    3.000000    3.000000    2.000000  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Age</th>\n      <th>Sex</th>\n      <th>RestBP</th>\n      <th>Chol</th>\n      <th>Fbs</th>\n      <th>RestECG</th>\n      <th>MaxHR</th>\n      <th>ExAng</th>\n      <th>Oldpeak</th>\n      <th>Slope</th>\n      <th>Ca</th>\n      <th>Thal</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>count</th>\n      <td>239.000000</td>\n      <td>239.000000</td>\n      <td>239.000000</td>\n      <td>239.000000</td>\n      <td>239.000000</td>\n      <td>239.000000</td>\n      <td>239.000000</td>\n      <td>239.000000</td>\n      <td>239.000000</td>\n      <td>239.000000</td>\n      <td>239.000000</td>\n      <td>239.000000</td>\n    </tr>\n    <tr>\n      <th>mean</th>\n      <td>54.602510</td>\n      <td>0.665272</td>\n      <td>130.958159</td>\n      <td>248.066946</td>\n      <td>0.133891</td>\n      <td>1.004184</td>\n      <td>149.661088</td>\n      <td>0.317992</td>\n      <td>1.047699</td>\n      <td>1.581590</td>\n      <td>0.661088</td>\n      <td>1.301255</td>\n    </tr>\n    <tr>\n      <th>std</th>\n      <td>9.170477</td>\n      <td>0.472886</td>\n      <td>16.700473</td>\n      <td>51.884930</td>\n      <td>0.341250</td>\n      <td>0.993669</td>\n      <td>23.658064</td>\n      <td>0.466674</td>\n      <td>1.140795</td>\n      <td>0.594651</td>\n      <td>0.920240</td>\n      <td>0.615997</td>\n    </tr>\n    <tr>\n      <th>min</th>\n      <td>29.000000</td>\n      <td>0.000000</td>\n      <td>94.000000</td>\n      <td>126.000000</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n      <td>71.000000</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>-1.000000</td>\n    </tr>\n    <tr>\n      <th>25%</th>\n      <td>48.000000</td>\n      <td>0.000000</td>\n      <td>120.000000</td>\n      <td>212.000000</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n      <td>132.500000</td>\n      <td>0.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n    </tr>\n    <tr>\n      <th>50%</th>\n      <td>56.000000</td>\n      <td>1.000000</td>\n      <td>130.000000</td>\n      <td>243.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n      <td>153.000000</td>\n      <td>0.000000</td>\n      <td>0.800000</td>\n      <td>2.000000</td>\n      <td>0.000000</td>\n      <td>1.000000</td>\n    </tr>\n    <tr>\n      <th>75%</th>\n      <td>61.000000</td>\n      <td>1.000000</td>\n      <td>140.000000</td>\n      <td>276.500000</td>\n      <td>0.000000</td>\n      <td>2.000000</td>\n      <td>166.500000</td>\n      <td>1.000000</td>\n      <td>1.600000</td>\n      <td>2.000000</td>\n      <td>1.000000</td>\n      <td>2.000000</td>\n    </tr>\n    <tr>\n      <th>max</th>\n      <td>77.000000</td>\n      <td>1.000000</td>\n      <td>192.000000</td>\n      <td>564.000000</td>\n      <td>1.000000</td>\n      <td>2.000000</td>\n      <td>202.000000</td>\n      <td>1.000000</td>\n      <td>6.200000</td>\n      <td>3.000000</td>\n      <td>3.000000</td>\n      <td>2.000000</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 15
    }
   ],
   "source": [
    "my_train_data_describe = my_train_data.describe()\n",
    "my_train_data_describe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "         count        mean        std    min    25%    50%    75%    max\n",
       "Age      239.0   54.602510   9.170477   29.0   48.0   56.0   61.0   77.0\n",
       "Sex      239.0    0.665272   0.472886    0.0    0.0    1.0    1.0    1.0\n",
       "RestBP   239.0  130.958159  16.700473   94.0  120.0  130.0  140.0  192.0\n",
       "Chol     239.0  248.066946  51.884930  126.0  212.0  243.0  276.5  564.0\n",
       "Fbs      239.0    0.133891   0.341250    0.0    0.0    0.0    0.0    1.0\n",
       "RestECG  239.0    1.004184   0.993669    0.0    0.0    1.0    2.0    2.0\n",
       "MaxHR    239.0  149.661088  23.658064   71.0  132.5  153.0  166.5  202.0\n",
       "ExAng    239.0    0.317992   0.466674    0.0    0.0    0.0    1.0    1.0\n",
       "Oldpeak  239.0    1.047699   1.140795    0.0    0.0    0.8    1.6    6.2\n",
       "Slope    239.0    1.581590   0.594651    1.0    1.0    2.0    2.0    3.0\n",
       "Ca       239.0    0.661088   0.920240    0.0    0.0    0.0    1.0    3.0\n",
       "Thal     239.0    1.301255   0.615997   -1.0    1.0    1.0    2.0    2.0"
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>count</th>\n      <th>mean</th>\n      <th>std</th>\n      <th>min</th>\n      <th>25%</th>\n      <th>50%</th>\n      <th>75%</th>\n      <th>max</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Age</th>\n      <td>239.0</td>\n      <td>54.602510</td>\n      <td>9.170477</td>\n      <td>29.0</td>\n      <td>48.0</td>\n      <td>56.0</td>\n      <td>61.0</td>\n      <td>77.0</td>\n    </tr>\n    <tr>\n      <th>Sex</th>\n      <td>239.0</td>\n      <td>0.665272</td>\n      <td>0.472886</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>1.0</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>RestBP</th>\n      <td>239.0</td>\n      <td>130.958159</td>\n      <td>16.700473</td>\n      <td>94.0</td>\n      <td>120.0</td>\n      <td>130.0</td>\n      <td>140.0</td>\n      <td>192.0</td>\n    </tr>\n    <tr>\n      <th>Chol</th>\n      <td>239.0</td>\n      <td>248.066946</td>\n      <td>51.884930</td>\n      <td>126.0</td>\n      <td>212.0</td>\n      <td>243.0</td>\n      <td>276.5</td>\n      <td>564.0</td>\n    </tr>\n    <tr>\n      <th>Fbs</th>\n      <td>239.0</td>\n      <td>0.133891</td>\n      <td>0.341250</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>RestECG</th>\n      <td>239.0</td>\n      <td>1.004184</td>\n      <td>0.993669</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>2.0</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>MaxHR</th>\n      <td>239.0</td>\n      <td>149.661088</td>\n      <td>23.658064</td>\n      <td>71.0</td>\n      <td>132.5</td>\n      <td>153.0</td>\n      <td>166.5</td>\n      <td>202.0</td>\n    </tr>\n    <tr>\n      <th>ExAng</th>\n      <td>239.0</td>\n      <td>0.317992</td>\n      <td>0.466674</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>Oldpeak</th>\n      <td>239.0</td>\n      <td>1.047699</td>\n      <td>1.140795</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.8</td>\n      <td>1.6</td>\n      <td>6.2</td>\n    </tr>\n    <tr>\n      <th>Slope</th>\n      <td>239.0</td>\n      <td>1.581590</td>\n      <td>0.594651</td>\n      <td>1.0</td>\n      <td>1.0</td>\n      <td>2.0</td>\n      <td>2.0</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>Ca</th>\n      <td>239.0</td>\n      <td>0.661088</td>\n      <td>0.920240</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>Thal</th>\n      <td>239.0</td>\n      <td>1.301255</td>\n      <td>0.615997</td>\n      <td>-1.0</td>\n      <td>1.0</td>\n      <td>1.0</td>\n      <td>2.0</td>\n      <td>2.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 16
    }
   ],
   "source": [
    "des = my_train_data_describe.transpose()\n",
    "des"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "def norm(x):  #标准化数据\n",
    "    desc = x.describe().transpose()\n",
    "    return (x-desc['mean'])/desc['std']\n",
    "\n",
    "# def norm(x):\n",
    "#     desc = x.describe().transpose()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "normed_my_train_data = norm(my_train_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "          Age       Sex    RestBP      Chol       Fbs   RestECG     MaxHR  \\\n",
       "204 -1.265203  0.707841 -1.254944 -0.714407 -0.392355 -1.010582  0.479283   \n",
       "114  0.806664 -1.406835 -0.057373  0.287811 -0.392355 -1.010582 -2.225926   \n",
       "164 -0.719975  0.707841 -0.416644  0.133624  2.538047 -1.010582  1.071048   \n",
       "279  0.370481 -1.406835 -0.057373 -0.984235 -0.392355 -1.010582 -0.788783   \n",
       "295 -1.483294  0.707841 -0.656159 -1.755171 -0.392355 -1.010582  1.366930   \n",
       "\n",
       "        ExAng   Oldpeak     Slope        Ca      Thal  \n",
       "204 -0.681401 -0.918394 -0.978037 -0.718387  1.134332  \n",
       "114 -0.681401  0.133505  0.703623  0.368287  1.134332  \n",
       "164 -0.681401 -0.918394 -0.978037  1.454960 -0.489053  \n",
       "279 -0.681401 -0.392445  0.703623 -0.718387 -0.489053  \n",
       "295 -0.681401 -0.918394 -0.978037 -0.718387 -0.489053  "
      ],
      "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Age</th>\n      <th>Sex</th>\n      <th>RestBP</th>\n      <th>Chol</th>\n      <th>Fbs</th>\n      <th>RestECG</th>\n      <th>MaxHR</th>\n      <th>ExAng</th>\n      <th>Oldpeak</th>\n      <th>Slope</th>\n      <th>Ca</th>\n      <th>Thal</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>204</th>\n      <td>-1.265203</td>\n      <td>0.707841</td>\n      <td>-1.254944</td>\n      <td>-0.714407</td>\n      <td>-0.392355</td>\n      <td>-1.010582</td>\n      <td>0.479283</td>\n      <td>-0.681401</td>\n      <td>-0.918394</td>\n      <td>-0.978037</td>\n      <td>-0.718387</td>\n      <td>1.134332</td>\n    </tr>\n    <tr>\n      <th>114</th>\n      <td>0.806664</td>\n      <td>-1.406835</td>\n      <td>-0.057373</td>\n      <td>0.287811</td>\n      <td>-0.392355</td>\n      <td>-1.010582</td>\n      <td>-2.225926</td>\n      <td>-0.681401</td>\n      <td>0.133505</td>\n      <td>0.703623</td>\n      <td>0.368287</td>\n      <td>1.134332</td>\n    </tr>\n    <tr>\n      <th>164</th>\n      <td>-0.719975</td>\n      <td>0.707841</td>\n      <td>-0.416644</td>\n      <td>0.133624</td>\n      <td>2.538047</td>\n      <td>-1.010582</td>\n      <td>1.071048</td>\n      <td>-0.681401</td>\n      <td>-0.918394</td>\n      <td>-0.978037</td>\n      <td>1.454960</td>\n      <td>-0.489053</td>\n    </tr>\n    <tr>\n      <th>279</th>\n      <td>0.370481</td>\n      <td>-1.406835</td>\n      <td>-0.057373</td>\n      <td>-0.984235</td>\n      <td>-0.392355</td>\n      <td>-1.010582</td>\n      <td>-0.788783</td>\n      <td>-0.681401</td>\n      <td>-0.392445</td>\n      <td>0.703623</td>\n      <td>-0.718387</td>\n      <td>-0.489053</td>\n    </tr>\n    <tr>\n      <th>295</th>\n      <td>-1.483294</td>\n      <td>0.707841</td>\n      <td>-0.656159</td>\n      <td>-1.755171</td>\n      <td>-0.392355</td>\n      <td>-1.010582</td>\n      <td>1.366930</td>\n      <td>-0.681401</td>\n      <td>-0.918394</td>\n      <td>-0.978037</td>\n      <td>-0.718387</td>\n      <td>-0.489053</td>\n    </tr>\n  </tbody>\n</table>\n</div>"
     },
     "metadata": {},
     "execution_count": 20
    }
   ],
   "source": [
    "normed_my_train_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "239"
      ]
     },
     "metadata": {},
     "execution_count": 21
    }
   ],
   "source": [
    "len(normed_my_train_data.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "dataset = tf.data.Dataset.from_tensor_slices((normed_my_train_data.values,target.values))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {},
   "outputs": [],
   "source": [
    "# train_dataset = dataset.shuffle(len(df)).batch(15)\n",
    "train_dataset = dataset.shuffle(len(dataset)).batch(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "tf.Tensor(\n[-1.26520256  0.7078414  -1.25494402 -0.71440678 -0.39235514 -1.01058246\n  0.47928318 -0.68140062 -0.9183937  -0.9780366  -0.71838671  1.13433161], shape=(12,), dtype=float64) (12,) 1 tf.Tensor(0, shape=(), dtype=int8)\n\ntf.Tensor(\n[ 0.80666359 -1.40683478 -0.05737316  0.28781102 -0.39235514 -1.01058246\n -2.22592551 -0.68140062  0.13350452  0.70362345  0.36828686  1.13433161], shape=(12,), dtype=float64) (12,) 1 tf.Tensor(1, shape=(), dtype=int8)\n\ntf.Tensor(\n[-0.71997463  0.7078414  -0.41664442  0.13362366  2.5380473  -1.01058246\n  1.07104759 -0.68140062 -0.9183937  -0.9780366   1.45496043 -0.48905315], shape=(12,), dtype=float64) (12,) 1 tf.Tensor(0, shape=(), dtype=int8)\n\ntf.Tensor(\n[ 0.37048124 -1.40683478 -0.05737316 -0.98423465 -0.39235514 -1.01058246\n -0.78878339 -0.68140062 -0.39244459  0.70362345 -0.71838671 -0.48905315], shape=(12,), dtype=float64) (12,) 1 tf.Tensor(0, shape=(), dtype=int8)\n\ntf.Tensor(\n[-1.48329374  0.7078414  -0.65615859 -1.75517142 -0.39235514 -1.01058246\n  1.36692979 -0.68140062 -0.9183937  -0.9780366  -0.71838671 -0.48905315], shape=(12,), dtype=float64) (12,) 1 tf.Tensor(0, shape=(), dtype=int8)\n\n"
     ]
    }
   ],
   "source": [
    "for feat,targ in dataset.take(5):\n",
    "    print(feat,feat.shape,feat.ndim,targ)\n",
    "    print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "24"
      ]
     },
     "metadata": {},
     "execution_count": 91
    }
   ],
   "source": [
    "len(train_dataset)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<BatchDataset shapes: ((None, 12), (None,)), types: (tf.float64, tf.int8)>"
      ]
     },
     "metadata": {},
     "execution_count": 92
    }
   ],
   "source": [
    "train_dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "metadata": {},
   "outputs": [],
   "source": [
    "#创建模型\n",
    "\n",
    "model = tf.keras.Sequential([\n",
    "    tf.keras.layers.Dense(16,input_shape=(12,),activation='relu',name=\"D1\"),\n",
    "    tf.keras.layers.BatchNormalization(),\n",
    "    tf.keras.layers.Dense(32,activation='relu',name=\"D2\"),\n",
    "    tf.keras.layers.Dropout(0.2),\n",
    "    tf.keras.layers.Dense(64,activation='relu',name=\"D3\"),\n",
    "    tf.keras.layers.BatchNormalization(),\n",
    "    tf.keras.layers.Dense(128,activation='relu'),\n",
    "    tf.keras.layers.BatchNormalization(),\n",
    "    tf.keras.layers.Dense(64,activation='relu',name=\"D4\"),\n",
    "    tf.keras.layers.Dropout(0.2),\n",
    "    tf.keras.layers.Dense(16,activation='relu',name=\"D5\"),\n",
    "    tf.keras.layers.BatchNormalization(),\n",
    "    tf.keras.layers.Dense(1,activation='sigmoid',name=\"D6\")\n",
    "    # tf.keras.layers.Dense(1,activation='tanh',name=\"D6\")\n",
    "    # tf.keras.layers.Dense(1,activation='relu',name=\"D6\")\n",
    "])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "metadata": {},
   "outputs": [],
   "source": [
    "optimizer = tf.keras.optimizers.RMSprop(0.00001)\n",
    "# optimizer = tf.keras.optimizers.Adam(0.0000001)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "metadata": {},
   "outputs": [],
   "source": [
    "#编译模型\n",
    "model.compile(optimizer=optimizer,\n",
    "              loss='binary_crossentropy',\n",
    "              metrics=['accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Model: \"sequential_15\"\n_________________________________________________________________\nLayer (type)                 Output Shape              Param #   \n=================================================================\nD1 (Dense)                   (None, 16)                208       \n_________________________________________________________________\nbatch_normalization_31 (Batc (None, 16)                64        \n_________________________________________________________________\nD2 (Dense)                   (None, 32)                544       \n_________________________________________________________________\ndropout_20 (Dropout)         (None, 32)                0         \n_________________________________________________________________\nD3 (Dense)                   (None, 64)                2112      \n_________________________________________________________________\nbatch_normalization_32 (Batc (None, 64)                256       \n_________________________________________________________________\ndense (Dense)                (None, 128)               8320      \n_________________________________________________________________\ndropout_21 (Dropout)         (None, 128)               0         \n_________________________________________________________________\nD5 (Dense)                   (None, 16)                2064      \n_________________________________________________________________\nbatch_normalization_33 (Batc (None, 16)                64        \n_________________________________________________________________\nD6 (Dense)                   (None, 1)                 17        \n=================================================================\nTotal params: 13,649\nTrainable params: 13,457\nNon-trainable params: 192\n_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "model.summary()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {
    "tags": [
     "outputPrepend"
    ]
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      " accuracy: 0.8577\n",
      "Epoch 1807/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3861 - accuracy: 0.8368\n",
      "Epoch 1808/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3973 - accuracy: 0.8201\n",
      "Epoch 1809/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3919 - accuracy: 0.8075\n",
      "Epoch 1810/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4049 - accuracy: 0.8243\n",
      "Epoch 1811/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3617 - accuracy: 0.8410\n",
      "Epoch 1812/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3830 - accuracy: 0.8285\n",
      "Epoch 1813/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3743 - accuracy: 0.8452\n",
      "Epoch 1814/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3455 - accuracy: 0.8159\n",
      "Epoch 1815/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4309 - accuracy: 0.8075\n",
      "Epoch 1816/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4496 - accuracy: 0.7908\n",
      "Epoch 1817/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4052 - accuracy: 0.8243\n",
      "Epoch 1818/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4006 - accuracy: 0.8285\n",
      "Epoch 1819/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4031 - accuracy: 0.8368\n",
      "Epoch 1820/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3827 - accuracy: 0.8117\n",
      "Epoch 1821/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4181 - accuracy: 0.8201\n",
      "Epoch 1822/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4877 - accuracy: 0.7992\n",
      "Epoch 1823/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4217 - accuracy: 0.8201\n",
      "Epoch 1824/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3844 - accuracy: 0.8661\n",
      "Epoch 1825/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3991 - accuracy: 0.8159\n",
      "Epoch 1826/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4496 - accuracy: 0.7992\n",
      "Epoch 1827/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4237 - accuracy: 0.8410\n",
      "Epoch 1828/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3849 - accuracy: 0.8243\n",
      "Epoch 1829/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3696 - accuracy: 0.8452\n",
      "Epoch 1830/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3754 - accuracy: 0.8410\n",
      "Epoch 1831/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3798 - accuracy: 0.8243\n",
      "Epoch 1832/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3729 - accuracy: 0.8075\n",
      "Epoch 1833/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3670 - accuracy: 0.8577\n",
      "Epoch 1834/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3921 - accuracy: 0.8201\n",
      "Epoch 1835/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4287 - accuracy: 0.8117\n",
      "Epoch 1836/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4023 - accuracy: 0.8326\n",
      "Epoch 1837/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4432 - accuracy: 0.8201\n",
      "Epoch 1838/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4053 - accuracy: 0.8285\n",
      "Epoch 1839/2000\n",
      "24/24 [==============================] - 0s 2ms/step - loss: 0.3584 - accuracy: 0.8159\n",
      "Epoch 1840/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3962 - accuracy: 0.8243\n",
      "Epoch 1841/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3958 - accuracy: 0.8452\n",
      "Epoch 1842/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3975 - accuracy: 0.8201\n",
      "Epoch 1843/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4145 - accuracy: 0.8201\n",
      "Epoch 1844/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3701 - accuracy: 0.8494\n",
      "Epoch 1845/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3641 - accuracy: 0.8410\n",
      "Epoch 1846/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3972 - accuracy: 0.8117\n",
      "Epoch 1847/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4103 - accuracy: 0.8159\n",
      "Epoch 1848/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3911 - accuracy: 0.8201\n",
      "Epoch 1849/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4269 - accuracy: 0.7824\n",
      "Epoch 1850/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4562 - accuracy: 0.7992\n",
      "Epoch 1851/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4393 - accuracy: 0.7992\n",
      "Epoch 1852/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3958 - accuracy: 0.8117\n",
      "Epoch 1853/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4040 - accuracy: 0.8536\n",
      "Epoch 1854/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3824 - accuracy: 0.8075\n",
      "Epoch 1855/2000\n",
      "24/24 [==============================] - 0s 2ms/step - loss: 0.3580 - accuracy: 0.8285\n",
      "Epoch 1856/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3731 - accuracy: 0.8452\n",
      "Epoch 1857/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3555 - accuracy: 0.8494\n",
      "Epoch 1858/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3824 - accuracy: 0.8201\n",
      "Epoch 1859/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3676 - accuracy: 0.8410\n",
      "Epoch 1860/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4638 - accuracy: 0.7908\n",
      "Epoch 1861/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3851 - accuracy: 0.8159\n",
      "Epoch 1862/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4355 - accuracy: 0.8033\n",
      "Epoch 1863/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4203 - accuracy: 0.7824\n",
      "Epoch 1864/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4164 - accuracy: 0.7908\n",
      "Epoch 1865/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4164 - accuracy: 0.8117\n",
      "Epoch 1866/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3958 - accuracy: 0.8326\n",
      "Epoch 1867/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3724 - accuracy: 0.8494\n",
      "Epoch 1868/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4167 - accuracy: 0.8243\n",
      "Epoch 1869/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3868 - accuracy: 0.8368\n",
      "Epoch 1870/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3938 - accuracy: 0.8285\n",
      "Epoch 1871/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4383 - accuracy: 0.8368\n",
      "Epoch 1872/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3993 - accuracy: 0.7866\n",
      "Epoch 1873/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4137 - accuracy: 0.8117\n",
      "Epoch 1874/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3869 - accuracy: 0.8494\n",
      "Epoch 1875/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3779 - accuracy: 0.8368\n",
      "Epoch 1876/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3662 - accuracy: 0.8285\n",
      "Epoch 1877/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4106 - accuracy: 0.7992\n",
      "Epoch 1878/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3836 - accuracy: 0.8285\n",
      "Epoch 1879/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3841 - accuracy: 0.8243\n",
      "Epoch 1880/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3419 - accuracy: 0.8410\n",
      "Epoch 1881/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4054 - accuracy: 0.8033\n",
      "Epoch 1882/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4104 - accuracy: 0.7992\n",
      "Epoch 1883/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3890 - accuracy: 0.8494\n",
      "Epoch 1884/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3956 - accuracy: 0.8494\n",
      "Epoch 1885/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3875 - accuracy: 0.8619\n",
      "Epoch 1886/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4255 - accuracy: 0.8033\n",
      "Epoch 1887/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3733 - accuracy: 0.8619\n",
      "Epoch 1888/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4162 - accuracy: 0.8201\n",
      "Epoch 1889/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3954 - accuracy: 0.8075\n",
      "Epoch 1890/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4507 - accuracy: 0.7950\n",
      "Epoch 1891/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4194 - accuracy: 0.8033\n",
      "Epoch 1892/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3872 - accuracy: 0.8368\n",
      "Epoch 1893/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3956 - accuracy: 0.8159\n",
      "Epoch 1894/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3708 - accuracy: 0.8326\n",
      "Epoch 1895/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4126 - accuracy: 0.8243\n",
      "Epoch 1896/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4321 - accuracy: 0.8075\n",
      "Epoch 1897/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4243 - accuracy: 0.8243\n",
      "Epoch 1898/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3401 - accuracy: 0.8870\n",
      "Epoch 1899/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4462 - accuracy: 0.7992\n",
      "Epoch 1900/2000\n",
      "24/24 [==============================] - 0s 2ms/step - loss: 0.3823 - accuracy: 0.8410\n",
      "Epoch 1901/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4197 - accuracy: 0.8285\n",
      "Epoch 1902/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3661 - accuracy: 0.8285\n",
      "Epoch 1903/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4226 - accuracy: 0.8075\n",
      "Epoch 1904/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4242 - accuracy: 0.8075\n",
      "Epoch 1905/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3889 - accuracy: 0.8243\n",
      "Epoch 1906/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4107 - accuracy: 0.8326\n",
      "Epoch 1907/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3594 - accuracy: 0.8410\n",
      "Epoch 1908/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4432 - accuracy: 0.8117\n",
      "Epoch 1909/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3454 - accuracy: 0.8326\n",
      "Epoch 1910/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3508 - accuracy: 0.8452\n",
      "Epoch 1911/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3877 - accuracy: 0.8368\n",
      "Epoch 1912/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3851 - accuracy: 0.8243\n",
      "Epoch 1913/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4317 - accuracy: 0.8033\n",
      "Epoch 1914/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3844 - accuracy: 0.8033\n",
      "Epoch 1915/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3825 - accuracy: 0.8243\n",
      "Epoch 1916/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3781 - accuracy: 0.8159\n",
      "Epoch 1917/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3821 - accuracy: 0.8243\n",
      "Epoch 1918/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4141 - accuracy: 0.8285\n",
      "Epoch 1919/2000\n",
      "24/24 [==============================] - 0s 2ms/step - loss: 0.3856 - accuracy: 0.8285\n",
      "Epoch 1920/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4086 - accuracy: 0.8159\n",
      "Epoch 1921/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3627 - accuracy: 0.8285\n",
      "Epoch 1922/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4536 - accuracy: 0.7657\n",
      "Epoch 1923/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3546 - accuracy: 0.8536\n",
      "Epoch 1924/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3846 - accuracy: 0.7992\n",
      "Epoch 1925/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3846 - accuracy: 0.8577\n",
      "Epoch 1926/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3894 - accuracy: 0.8075\n",
      "Epoch 1927/2000\n",
      "24/24 [==============================] - 0s 2ms/step - loss: 0.4042 - accuracy: 0.8243\n",
      "Epoch 1928/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4360 - accuracy: 0.8159\n",
      "Epoch 1929/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4003 - accuracy: 0.8117\n",
      "Epoch 1930/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4064 - accuracy: 0.8117\n",
      "Epoch 1931/2000\n",
      "24/24 [==============================] - 0s 2ms/step - loss: 0.4462 - accuracy: 0.8033\n",
      "Epoch 1932/2000\n",
      "24/24 [==============================] - 0s 2ms/step - loss: 0.4354 - accuracy: 0.7992\n",
      "Epoch 1933/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4024 - accuracy: 0.8494\n",
      "Epoch 1934/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4146 - accuracy: 0.8201\n",
      "Epoch 1935/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4322 - accuracy: 0.8075\n",
      "Epoch 1936/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4129 - accuracy: 0.8117\n",
      "Epoch 1937/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4119 - accuracy: 0.8285\n",
      "Epoch 1938/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3769 - accuracy: 0.8536\n",
      "Epoch 1939/2000\n",
      "24/24 [==============================] - 0s 2ms/step - loss: 0.3711 - accuracy: 0.8494\n",
      "Epoch 1940/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3889 - accuracy: 0.8033\n",
      "Epoch 1941/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4193 - accuracy: 0.8159\n",
      "Epoch 1942/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3579 - accuracy: 0.8577\n",
      "Epoch 1943/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3721 - accuracy: 0.8117\n",
      "Epoch 1944/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4056 - accuracy: 0.8117\n",
      "Epoch 1945/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3829 - accuracy: 0.8201\n",
      "Epoch 1946/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4284 - accuracy: 0.8159\n",
      "Epoch 1947/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4340 - accuracy: 0.7824\n",
      "Epoch 1948/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3550 - accuracy: 0.8452\n",
      "Epoch 1949/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3642 - accuracy: 0.8452\n",
      "Epoch 1950/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3688 - accuracy: 0.8452\n",
      "Epoch 1951/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3867 - accuracy: 0.8285\n",
      "Epoch 1952/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3701 - accuracy: 0.8452\n",
      "Epoch 1953/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3791 - accuracy: 0.8410\n",
      "Epoch 1954/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3625 - accuracy: 0.8452\n",
      "Epoch 1955/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3869 - accuracy: 0.8117\n",
      "Epoch 1956/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4247 - accuracy: 0.8033\n",
      "Epoch 1957/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3570 - accuracy: 0.8494\n",
      "Epoch 1958/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4303 - accuracy: 0.7950\n",
      "Epoch 1959/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4174 - accuracy: 0.8201\n",
      "Epoch 1960/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3294 - accuracy: 0.8787\n",
      "Epoch 1961/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3503 - accuracy: 0.8536\n",
      "Epoch 1962/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4003 - accuracy: 0.8117\n",
      "Epoch 1963/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4247 - accuracy: 0.8075\n",
      "Epoch 1964/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4257 - accuracy: 0.8075\n",
      "Epoch 1965/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3723 - accuracy: 0.8410\n",
      "Epoch 1966/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3388 - accuracy: 0.8577\n",
      "Epoch 1967/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4487 - accuracy: 0.7866\n",
      "Epoch 1968/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3558 - accuracy: 0.8368\n",
      "Epoch 1969/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4167 - accuracy: 0.7866\n",
      "Epoch 1970/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4462 - accuracy: 0.7992\n",
      "Epoch 1971/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4028 - accuracy: 0.8117\n",
      "Epoch 1972/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4041 - accuracy: 0.8243\n",
      "Epoch 1973/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3636 - accuracy: 0.8201\n",
      "Epoch 1974/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3329 - accuracy: 0.8661\n",
      "Epoch 1975/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4236 - accuracy: 0.8033\n",
      "Epoch 1976/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3953 - accuracy: 0.8075\n",
      "Epoch 1977/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3443 - accuracy: 0.8368\n",
      "Epoch 1978/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3298 - accuracy: 0.8368\n",
      "Epoch 1979/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4144 - accuracy: 0.8285\n",
      "Epoch 1980/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4190 - accuracy: 0.8033\n",
      "Epoch 1981/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3689 - accuracy: 0.8243\n",
      "Epoch 1982/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4161 - accuracy: 0.8452\n",
      "Epoch 1983/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4385 - accuracy: 0.7992\n",
      "Epoch 1984/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3900 - accuracy: 0.8410\n",
      "Epoch 1985/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3775 - accuracy: 0.8410\n",
      "Epoch 1986/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3688 - accuracy: 0.8243\n",
      "Epoch 1987/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3358 - accuracy: 0.8285\n",
      "Epoch 1988/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3865 - accuracy: 0.8368\n",
      "Epoch 1989/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3921 - accuracy: 0.8285\n",
      "Epoch 1990/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3931 - accuracy: 0.8494\n",
      "Epoch 1991/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4020 - accuracy: 0.7992\n",
      "Epoch 1992/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4188 - accuracy: 0.8159\n",
      "Epoch 1993/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3823 - accuracy: 0.8285\n",
      "Epoch 1994/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.4373 - accuracy: 0.8033\n",
      "Epoch 1995/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3956 - accuracy: 0.8075\n",
      "Epoch 1996/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3928 - accuracy: 0.8117\n",
      "Epoch 1997/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3567 - accuracy: 0.8410\n",
      "Epoch 1998/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3861 - accuracy: 0.8243\n",
      "Epoch 1999/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3886 - accuracy: 0.8452\n",
      "Epoch 2000/2000\n",
      "24/24 [==============================] - 0s 1ms/step - loss: 0.3651 - accuracy: 0.8410\n"
     ]
    },
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<tensorflow.python.keras.callbacks.History at 0x20c18f82f28>"
      ]
     },
     "metadata": {},
     "execution_count": 140
    }
   ],
   "source": [
    "model.fit(train_dataset, epochs=2000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_data =[ 41.0,0,130,204,0,2,172,0,1.4 ,1, 0, 1]\n",
    "test_data = tf.constant(test_data,dtype=tf.float64)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_data = (test_data-des['mean'])/des['std']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "(12,) 1\n"
     ]
    }
   ],
   "source": [
    "print(test_data.shape,test_data.ndim)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "TensorShape([1, 12])"
      ]
     },
     "metadata": {},
     "execution_count": 158
    }
   ],
   "source": [
    "test2 = tf.expand_dims(test_data,axis=0)\n",
    "test2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "array([[0.01293752]], dtype=float32)"
      ]
     },
     "metadata": {},
     "execution_count": 159
    }
   ],
   "source": [
    "predict = model.predict(test2)\n",
    "predict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "TensorShape([1, 12])"
      ]
     },
     "metadata": {},
     "execution_count": 70
    }
   ],
   "source": [
    "test2 = tf.constant([67,1,120,229,0,\t2,129,1\t,2.6,\t2\t,2.0,2],dtype=tf.float64)\n",
    "test2 = tf.expand_dims(test2,axis=0)\n",
    "test2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "metadata": {},
   "outputs": [],
   "source": [
    "test2 = tf.expand_dims(test2,axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "metadata": {},
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(1, 12, 1), dtype=float64, numpy=\n",
       "array([[[-0.06580267],\n",
       "        [-0.60181118],\n",
       "        [ 1.097728  ],\n",
       "        [ 2.065158  ],\n",
       "        [-0.60181118],\n",
       "        [-0.57566443],\n",
       "        [ 1.64680989],\n",
       "        [-0.60181118],\n",
       "        [-0.58350845],\n",
       "        [-0.5887378 ],\n",
       "        [-0.60181118],\n",
       "        [-0.5887378 ]]])>"
      ]
     },
     "metadata": {},
     "execution_count": 153
    }
   ],
   "source": [
    "test2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "metadata": {},
   "outputs": [
    {
     "output_type": "error",
     "ename": "ValueError",
     "evalue": "in user code:\n\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py:1462 predict_function  *\n        return step_function(self, iterator)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py:1452 step_function  **\n        outputs = model.distribute_strategy.run(run_step, args=(data,))\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\distribute\\distribute_lib.py:1211 run\n        return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\distribute\\distribute_lib.py:2585 call_for_each_replica\n        return self._call_for_each_replica(fn, args, kwargs)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\distribute\\distribute_lib.py:2945 _call_for_each_replica\n        return fn(*args, **kwargs)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py:1445 run_step  **\n        outputs = model.predict_step(data)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py:1418 predict_step\n        return self(x, training=False)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\base_layer.py:976 __call__\n        self.name)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\input_spec.py:216 assert_input_compatibility\n        ' but received input with shape ' + str(shape))\n\n    ValueError: Input 0 of layer sequential_17 is incompatible with the layer: expected axis -1 of input shape to have value 12 but received input with shape [None, 12, 1]\n",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-154-773386ef42fd>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mpredict2\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmodel\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpredict\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtest2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[0mpredict2\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py\u001b[0m in \u001b[0;36m_method_wrapper\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m    128\u001b[0m       raise ValueError('{} is not supported in multi-worker mode.'.format(\n\u001b[0;32m    129\u001b[0m           method.__name__))\n\u001b[1;32m--> 130\u001b[1;33m     \u001b[1;32mreturn\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    131\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    132\u001b[0m   return tf_decorator.make_decorator(\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py\u001b[0m in \u001b[0;36mpredict\u001b[1;34m(self, x, batch_size, verbose, steps, callbacks, max_queue_size, workers, use_multiprocessing)\u001b[0m\n\u001b[0;32m   1597\u001b[0m           \u001b[1;32mfor\u001b[0m \u001b[0mstep\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mdata_handler\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msteps\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1598\u001b[0m             \u001b[0mcallbacks\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mon_predict_batch_begin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstep\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1599\u001b[1;33m             \u001b[0mtmp_batch_outputs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpredict_function\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0miterator\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1600\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mdata_handler\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mshould_sync\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1601\u001b[0m               \u001b[0mcontext\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0masync_wait\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\eager\\def_function.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m    778\u001b[0m       \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    779\u001b[0m         \u001b[0mcompiler\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"nonXla\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 780\u001b[1;33m         \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_call\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    781\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    782\u001b[0m       \u001b[0mnew_tracing_count\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_tracing_count\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\eager\\def_function.py\u001b[0m in \u001b[0;36m_call\u001b[1;34m(self, *args, **kwds)\u001b[0m\n\u001b[0;32m    812\u001b[0m       \u001b[1;31m# In this case we have not created variables on the first call. So we can\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    813\u001b[0m       \u001b[1;31m# run the first trace but we should fail if variables are created.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 814\u001b[1;33m       \u001b[0mresults\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_stateful_fn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    815\u001b[0m       \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_created_variables\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    816\u001b[0m         raise ValueError(\"Creating variables on a non-first call to a function\"\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\eager\\function.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m   2826\u001b[0m     \u001b[1;34m\"\"\"Calls a graph function specialized to the inputs.\"\"\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2827\u001b[0m     \u001b[1;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_lock\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2828\u001b[1;33m       \u001b[0mgraph_function\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_maybe_define_function\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2829\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_filtered_call\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m  \u001b[1;31m# pylint: disable=protected-access\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2830\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\eager\\function.py\u001b[0m in \u001b[0;36m_maybe_define_function\u001b[1;34m(self, args, kwargs)\u001b[0m\n\u001b[0;32m   3208\u001b[0m           \u001b[1;32mand\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minput_signature\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3209\u001b[0m           and call_context_key in self._function_cache.missed):\n\u001b[1;32m-> 3210\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_define_function_with_shape_relaxation\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3211\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3212\u001b[0m       \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_function_cache\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmissed\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0madd\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcall_context_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\eager\\function.py\u001b[0m in \u001b[0;36m_define_function_with_shape_relaxation\u001b[1;34m(self, args, kwargs)\u001b[0m\n\u001b[0;32m   3140\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3141\u001b[0m     graph_function = self._create_graph_function(\n\u001b[1;32m-> 3142\u001b[1;33m         args, kwargs, override_flat_arg_shapes=relaxed_arg_shapes)\n\u001b[0m\u001b[0;32m   3143\u001b[0m     \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_function_cache\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0marg_relaxed\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mrank_only_cache_key\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3144\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\eager\\function.py\u001b[0m in \u001b[0;36m_create_graph_function\u001b[1;34m(self, args, kwargs, override_flat_arg_shapes)\u001b[0m\n\u001b[0;32m   3073\u001b[0m             \u001b[0marg_names\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0marg_names\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3074\u001b[0m             \u001b[0moverride_flat_arg_shapes\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0moverride_flat_arg_shapes\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3075\u001b[1;33m             capture_by_value=self._capture_by_value),\n\u001b[0m\u001b[0;32m   3076\u001b[0m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_function_attributes\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3077\u001b[0m         \u001b[0mfunction_spec\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mfunction_spec\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\framework\\func_graph.py\u001b[0m in \u001b[0;36mfunc_graph_from_py_func\u001b[1;34m(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, override_flat_arg_shapes)\u001b[0m\n\u001b[0;32m    984\u001b[0m         \u001b[0m_\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0moriginal_func\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtf_decorator\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0munwrap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpython_func\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    985\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 986\u001b[1;33m       \u001b[0mfunc_outputs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpython_func\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mfunc_args\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mfunc_kwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    987\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    988\u001b[0m       \u001b[1;31m# invariant: `func_outputs` contains only Tensors, CompositeTensors,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\eager\\def_function.py\u001b[0m in \u001b[0;36mwrapped_fn\u001b[1;34m(*args, **kwds)\u001b[0m\n\u001b[0;32m    598\u001b[0m         \u001b[1;31m# __wrapped__ allows AutoGraph to swap in a converted function. We give\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    599\u001b[0m         \u001b[1;31m# the function a weak reference to itself to avoid a reference cycle.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 600\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[0mweak_wrapped_fn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__wrapped__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    601\u001b[0m     \u001b[0mweak_wrapped_fn\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mweakref\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mref\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mwrapped_fn\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    602\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\framework\\func_graph.py\u001b[0m in \u001b[0;36mwrapper\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    971\u001b[0m           \u001b[1;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m  \u001b[1;31m# pylint:disable=broad-except\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    972\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0me\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"ag_error_metadata\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 973\u001b[1;33m               \u001b[1;32mraise\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mag_error_metadata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mto_exception\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0me\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    974\u001b[0m             \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    975\u001b[0m               \u001b[1;32mraise\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mValueError\u001b[0m: in user code:\n\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py:1462 predict_function  *\n        return step_function(self, iterator)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py:1452 step_function  **\n        outputs = model.distribute_strategy.run(run_step, args=(data,))\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\distribute\\distribute_lib.py:1211 run\n        return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\distribute\\distribute_lib.py:2585 call_for_each_replica\n        return self._call_for_each_replica(fn, args, kwargs)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\distribute\\distribute_lib.py:2945 _call_for_each_replica\n        return fn(*args, **kwargs)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py:1445 run_step  **\n        outputs = model.predict_step(data)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\training.py:1418 predict_step\n        return self(x, training=False)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\base_layer.py:976 __call__\n        self.name)\n    C:\\Python3_7_2\\lib\\site-packages\\tensorflow\\python\\keras\\engine\\input_spec.py:216 assert_input_compatibility\n        ' but received input with shape ' + str(shape))\n\n    ValueError: Input 0 of layer sequential_17 is incompatible with the layer: expected axis -1 of input shape to have value 12 but received input with shape [None, 12, 1]\n"
     ]
    }
   ],
   "source": [
    "predict2 = model.predict(test2)\n",
    "predict2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ]
}